from flask import Flask, request, make_response, render_template

app = Flask(__name__)


@app.route("/login", methods=["GET", "POST"])
def login():
    if request.method == "POST":
        username = request.form["username"]
        password = request.form["password"]
        print(f"用户名:{username},密码{password}")
        response = make_response("登录成功")
        # 返回自定义的响应头
        response.headers["X-Custom-Header"] = "value"
        return response
    else:
        return render_template("login.html", title="登录页面")


if __name__ == "__main__":
    app.run()
